import { IsString, IsNotEmpty, IsOptional, MaxLength } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

/**
 * 创建权限数据传输对象
 * 用于验证创建权限请求的数据格式
 */
export class CreatePermissionDto {
  /**
   * 权限名称
   */
  @ApiProperty({
    description: '权限名称',
    example: 'user:create',
    maxLength: 50,
  })
  @IsString()
  @IsNotEmpty()
  @MaxLength(50)
  name: string;

  /**
   * 权限描述
   */
  @ApiPropertyOptional({
    description: '权限描述',
    example: '创建用户',
    maxLength: 200,
  })
  @IsOptional()
  @IsString()
  @MaxLength(200)
  description?: string;

  /**
   * 资源
   */
  @ApiProperty({
    description: '资源',
    example: 'user',
    maxLength: 50,
  })
  @IsString()
  @IsNotEmpty()
  @MaxLength(50)
  resource: string;

  /**
   * 操作
   */
  @ApiProperty({
    description: '操作',
    example: 'create',
    maxLength: 50,
  })
  @IsString()
  @IsNotEmpty()
  @MaxLength(50)
  action: string;
}